<?php
if ($where = $_POST['where']) {
	
} else {
	$where = "WHERE `status`<'3' AND `review`!='' ";
}
$pre_print_result = mysql_query("SELECT * FROM `album` " . $where . " ORDER BY `status` ASC, `add_date` DESC");

echo('<h2>Select the albums for which you would like to print discriptions:</h2>');
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<fieldset><legend>Display Options</legend>
<label><input type="checkbox" checked="checked" name="description" value="true" /> require description</label>
<input type="hidden" name="cat" value="<?=$cat?>" />
<input type="hidden" name="mode" value="labelprint" />
<input type="submit" value="Go Go!" />
</fieldset>
</form>
<form action="<?php echo($HTTP_DIR . '/do/pdf_print_label.php') ?>" method="post">
<fieldset><legend>PDF Options</legend>
Labels Per Column: <select name="ColumnLimit"><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7" selected="selected">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select>
<input type="hidden" name="cat" value="<?=$cat?>" />
<input type="hidden" name="mode" value="labelprint" />
<input type="hidden" name="do" value="pdf_print_label" />
<input type="submit" value="Generate PDF" />
</fieldset>
<table>
<tr>
<td>Artist</td><td>Title</td><td>Add Date</td><td>Slot</td><td>Promoters</td><td></td><td></td><td></td>
</tr>
<?php
$print_cd_counter = 0;

if ($albPrint) {
   foreach ($albPrint as $newAlb) {
      $alb = mysql_fetch_array(mysql_query("SELECT * FROM `album` WHERE `cddbid`='".$newAlb[id]."' "));
      printf("<tr><td>
       <input name=\"print_id[%s]\" value=\"%s\" type=\"checkbox\" checked=\"checked\" />%s</td>
       <td>%s</td><td>%s</td><td>%s</td><td> </td><td>%s</td><td></td><td></td></tr>", 
       $print_cd_counter++, 
       $alb[cddbid], 
       $alb[artist], 
       $alb[title], 
       $alb[add_date], 
       $alb[slot], 
       $alb[status]);
   }
}
?>
<?php
if (!$albPrint) $albPrint = array();
while($row = mysql_fetch_assoc($pre_print_result)) { //show all the results from the above query
   if (!in_array($row[cddbid], $albPrint)){
      ?>
      <tr class="highlighted">
      <td><input name="print_id[<?=$print_cd_counter++?>]" value="<?=$row[cddbid]?>" type="checkbox" /><?=trunc($row[artist], 20)?></td>
      <td><?=trunc($row[title], 20)?></td>
      <td><?=str_replace('-', '', $row[add_date])?></td>
      <td>(<?=$row[slot] . $row[multi] ?>)</td>
      <td><?php echo($row[promoter]);
      if ($row[promoter2]) echo (', ' . $row[promoter2]);
      if ($row[promoter3]) echo (', ' . $row[promoter3]);
      ?></td>
      <td><?=$row[status]?></td>
      </tr>
<?php
   }
}
?></table>
</form>